package com.cy.pj.sys.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cy.pj.common.util.ShiroUtli;
import com.cy.pj.sys.pojo.SysUser;
import com.cy.pj.sys.pojo.SysUserMenu;
import com.cy.pj.sys.service.SysMenuService;


@Controller
@RequestMapping("/")
public class PageController {
	
	@Autowired
	private SysMenuService sysMenuService;
	
	
	@RequestMapping("doLoginUI")
	public String doLoginUI() {
		return "login";
	}
	
	//首页
	@RequestMapping("doIndexUI")
	public String doIndexUI(Model model) {
		SysUser user = ShiroUtli.getUser();
		model.addAttribute("user",user);
		List<SysUserMenu> userMenus = sysMenuService.findUserMenusByUserId(user.getId());
		model.addAttribute("userMenus",userMenus);
		return "starter";
	}
	
	//基于此方法返回分页页面
	@RequestMapping("doPageUI")
	public String doPageUI() {
		return "common/page";
	}
	
	
//	基于此方法返回日志列表页面
//	@RequestMapping("log/log_list")
//	public String doLogUI() {
//		return "sys/log_list";
//	}
//	
//	//基于此方法返回菜单管理页面
//	@RequestMapping("menu/menu_list")
//	public String doMenuUI() {
//	return "sys/menu_list";
//	}

	//rest风格的url,语法结构为{变量名}/{变量}
	//@PathVariable注解用于从rest风格的url中取参数名对应的值  
	@RequestMapping("{module}/{moduleUI}")
	public String doModuleUI(@PathVariable String moduleUI) {
	return "sys/"+moduleUI;
	}
	
}
